home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1986 December / Ahoy_Magazine_86-12_1986_Double_L.d64 / Diligent Decoder (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  506b  |  18 lines

  1. 0 rem << cd36-3 >>
  2. 1 rem commodares problem #32-1:
  3. 2 print"[147]           diligent decoder"
  4. 3 rem solution by
  5. 4 rem    matt shapiro
  6. 5 rem (also #28-4:elegant encoder)
  7. 6 rem
  8. 10 dim w(28):def fnm(x)=x-29*int(x/29)
  9. 20 input"what's your word";w$
  10. 30 print"e[146]ncode or d[146]ecode?  ";
  11. 40 get a$:if a$<"d" or a$>"e" then 40
  12. 50 print a$:l=len(w$):s=0:if l<2 or l>29 then 20
  13. 60 for i=1 to l:w(i)=asc(mid$(w$,i,1))-64:s=s+w(i):next:w$="":if a$="e" then100
  14. 70 s=fnm(s)
  15. 80 q=s/(l-1):ifq<>int(q) then s=s+29:goto 80
  16. 90 s=q
  17. 100 for i=1 to l:w$=w$+chr$(fnm(s-w(i))+64):next:print w$:end
  18.